﻿using System;

using OpenTK;

namespace MosCraft.Utilities
{
    public class RayTraceObject
    {
        public readonly RayTraceType typeOfHit;
        public readonly int blockX;
        public readonly int blockY;
        public readonly int blockZ;
        public readonly BlockFace side;
        public readonly int ID;
        public readonly Vector3d hitVec;
        public readonly Entity entityHit;

        public RayTraceObject(int x, int y, int z, BlockFace blockFace, int blockID)
        {
            typeOfHit = RayTraceType.Tile;
            blockX = x;
            blockY = y;
            blockZ = z;
            side = blockFace;
            ID = blockID;
        }

        public RayTraceObject(Entity entity)
        {
            typeOfHit = RayTraceType.Entity;
            entityHit = entity;
            hitVec = entity.Velocity;
        }

        public void ProjectBlockPlace(out int x, out int y, out int z)
        {
            x = blockX;
            y = blockY;
            z = blockZ;

            switch (side)
            {
                case BlockFace.Right: z++; break;
                case BlockFace.Left: z--; break;
                case BlockFace.Top: y++; break;
                case BlockFace.Bottom: y--; break;
                case BlockFace.Back: x++; break;
                case BlockFace.Front: x--; break;
            }
        }
    }
}
